package fr.excilys.gwt.communication.server;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

import fr.excilys.gwt.communication.shared.LoginService;
import fr.excilys.gwt.communication.shared.LoginException;
import fr.excilys.gwt.communication.shared.User;

public class LoginServiceImpl extends RemoteServiceServlet implements
		LoginService {

	private static final long serialVersionUID = -4428789659454343711L;

	@Override
	public User login(String username, String password) throws LoginException {
		if ("".equals(username)) {
			throw new LoginException(
					"Vous n'avez pas rempli de nom d'utilisateur.");
		} else if (!username.equals(password)) {
			throw new LoginException("Mauvais mot de passe.");
		}
		return new User(username);
	}

}
